import 'package:flutter/material.dart';

/**
 * StatefulWidget 实现一个技术器
 */
class StateFulWidget extends StatefulWidget {
  const  StateFulWidget({super.key});

  @override
  State<StateFulWidget> createState() => _StateFulWidgetState();
}

class _StateFulWidgetState extends State<StateFulWidget> {
  var count = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('StatefulWidget'),
      ),
      body: Center(
        child: Text(count.toString()),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          ///数据更新
          setState(() {
            count++;
            print(count.toString());
          });
        },
        child: Icon(Icons.add),
      ),
    );
  }
}
